<?php
/**
 * 标签名称，比如这个使用!{form }这样调用
 * @var string
 */
$self_tag_name = 'form';

/**
 * 执行某个挂件，比如!{form id='123456' name=''}
 * @param array $params 参数
 * @param Smarty $smarty
 */
function smarty_function_form($params, &$smarty){
	$options = array();
	if(isset($params['id'])){
		$options['id'] = trim($params['id']);
	}
	if(isset($params['name'])){
		$options['name'] = trim($params['name']);
	}
	if(isset($params['entity_id'])){
		$options['entity_id'] = trim($params['entity_id']);
	}elseif(isset($_REQUEST['id'])){
		$options['entity_id'] = trim($_REQUEST['id']);
	}
	
	if(isset($_REQUEST['item_id'])){
		$options['item_id'] = trim($_REQUEST['item_id']);
	}
	
	if(isset($params['model_name'])){
		$options['model_name'] = $params['model_name'];
	}
// 	print_r($options);exit;
	$h = new FormHelper($options);
	return $h->get_html();
}